/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GoLib-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GoConfTest.go			*/
/********************************************************/

package main

import (
	. "GoGlb"
	C "GoCls"
)

func main() {
	name := "./GoConfTest.conf"
	line := "# GoConfTest\n" +
		"# 2015-08-15\n" +
		"\n" +
		"[BASE]\n" +
		"LSTN = 8082				# listen\n" +
		"LOGS = /root/GoConfTest.log		# log path\n" +
		"\n" +
		"[MYSQL]\n" +
		"PORT = 3306				# mysql port\n" +
		"USER = root				# mysql user\n" +
		"PASS = 123456				# mysql pass\n" +
		"HOST = 192.168.0.100			# mysql host\n" +
		"DBNM = GoMysql				# mysql dbname\n"
	file := new(C.GoFile)
	if GO_SUCCESS == GoError(file.GoFileCreate(name)) {
		file.GoFileWrite([]byte(line))
		file.GoFileClose()
		/* read */
		conf := new(C.GoConf)
		if GO_SUCCESS == GoError(conf.GoConfOpen(name)) {
			conf.GoConfParse()
			conf.GoConfClose()
			conf.GoConfDisplay()
			for i := 0; ; i ++ {
				s, k, v := conf.GoConfRange(i)
				if 0 != len(s) && 0 != len(k) && 0 != len(v) {
					GoPrint("[%s]: %s -> %s\n", s, k, v)
				} else {
					break
				}
			}
		}
		file.GoFileDelete(name)
	}
}
